#!/bin/sh

kadmind_start() {
  if [ -x /usr/heimdal/libexec/kadmind ]; then
    echo "Starting the kadmind service: /usr/heimdal/libexec/kadmind"
    /usr/heimdal/libexec/kadmind --detach
  fi
}

kadmind_stop() {
  killall kadmind
}

kadmind_restart() {
  kadmind_stop
  sleep 1
  kadmind_start
}

case "$1" in
  'start')
    kadmind_start
  ;;
  'stop')
    kadmind_stop
  ;;
  'restart')
    kadmind_restart
  ;;
  *)
    echo "Usage: $0 start|stop|restart"
  ;;
esac

